<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			window.onload = function(){
				// 获取H1标题
				// document.getElementById("hh").style.fontSize = "28px";
				// document.getElementById("hh").style.color = "red";
				var h1 = document.getElementById("hh");
				// h1.innerText = "<div style='color:red';>大家辛苦了!</div>";
				h1.innerHTML = "<div style='color:red';>大家辛苦了!</div>";
				
				
			}
			function checkData(){
				alert("表单已提交!");
				// 获取用户名
				var uName = document.getElementsByName("userName")[0].value;
				if (uName == "admin"){ 	
					alert("用户名已经被占用了!");
				} else {
					alert("注册成功!");S
				}
				// 获取密码
				var pwd = document.getElementById("pwd").value;
				// console.log(typeof pwd);//String
				var newPwd = pwd.toString().length;
				if(newPwd >= 6 && newPwd <= 10) {
					alert("密码可用!");
				} else {
					alert("密码不可用!");
				}
				
			}
		</script>
	</head>
	<body>
		<h1 id="hh">欢迎光临!</h1>
		<form action="#" method="get" onsubmit="checkData();">
			用户名:<input type="text" name="userName" id="uNam" />
			密码:<input type="password" name="passWord" id="pwd" />
			<input type="radio" name="sex" value="男" />男
			<input type="radio" name="sex" value="女" />女
			<input type="submit"/>
		</form>
	</body>
</html>
